import requests
import json
from pyquery import PyQuery as jq

##有验证码问题。

url = "http://www.dianping.com/hangzhou/ch10/g110"
data = ""
headers = json.loads(r'''{
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Cache-Control": "max-age=0",
    "Connection": "keep-alive",
    "Cookie": "cy=3; cye=hangzhou; s_ViewType=10; _hc.v=f73f5125-8512-73ef-c3e6-df27a4b82c95.1533708948; dper=b3db6c388519b88b64411eb6e0b6149e2b144ff43a4cd0c41ba6f60d75c1a2dcca8a39ac75aee2ef317ef5c3fb3949206a7490bf8f64528d88312af74ec3085566019e7d80114ba87a3f9f2a84ddec94c7a4b6ae5a16c6df498cb0f9a960fa3d; ua=dpuser_62044819422; ctu=ebca364cca8bf9ef217e8d3cabb06ac5fcec304e27912e21fb47f87bf6a9442c; ll=7fd06e815b796be3df069dec7836c3df",
    "Host": "www.dianping.com",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
}''')

def getComment(urls):


## 获取商品列表
# def getList(urls):
# 	resp = requests.get(urls, data=data, headers=headers)
# 	for lis in jq(resp.text)('#shop-all-list > ul > li').items():
# 		top = lis('div.txt > div.tit > a:nth-child(1)')
# 		url = top.attr('href')
# 		title = top('h4').text()
# 		print(url)

## 获取翻页数据
# resp = requests.get(url, data=data, headers=headers)
# page = jq(resp.text)('body > div.section.Fix.J-shop-search > div.content-wrap > div.shop-wrap > div.page')
# for i in page('a').items():
# 	if i.attr('href'):
# 		getList(i.attr('href'))




    